$(document).ready(function () {
	//设置当前页面选中样式
	setting_style_the_page();
	function setting_style_the_page() {
		var first_menu_item = $('#sidebar-nav').find('a[href="#accounts-menu-first-03"]');//获取一级菜单可点击的a标签 "预警处理"
		var img_nav = first_menu_item.find('.define-nav');//获取导航图片
		var img_left = first_menu_item.find('.define-left');//获取转向图片
		var first_ul = $('#accounts-menu-first-03');//获取一级下拉菜单
		var first_ul_li_one = first_ul.children('li').eq(2);//获取  "报警卡绑定记录"

		first_menu_item.addClass('define-active');//一级菜单添加左边横线
		img_nav.attr('src','/statics/images/sever_center_select.png');//切换导航图片
		img_left.addClass('define-rotate-active');//添加动画类
		first_ul.addClass('in');//展拉一级菜单
		first_ul_li_one.addClass('define-active');//li添加左边横线
	}

	//分页切换效果
	page_style_switch();
	function page_style_switch() {
		var page_ = $('.define-paging');
		var the_first_page = $('#the_first_page');//获取首页
		var prev_page = $('#prev_page');//获取上一页
		var next_page = $('#next_page');//获取下一页
		var the_last_page = $('#the_last_page');//获取尾页

		// 123456
		page_.delegate('.define-page','click',function () {
			page_.find('.define-page').removeClass('define-active');
			$(this).addClass('define-active');
		});

		// 上一页
		prev_page.on('click',function () {
			var active_page = page_.find('.define-active');
			if(active_page.text() > 1){
				page_.find('.define-page').removeClass('define-active');
				active_page.prev().addClass('define-active')
			}
		});

		// 下一页
		next_page.on('click',function () {
			var active_page = page_.find('.define-active');
			if(active_page.text() < 5){
				page_.find('.define-page').removeClass('define-active');
				active_page.next().addClass('define-active')
			}
		});

		// 首页
		the_first_page.on('click',function () {
			page_.find('.define-page').removeClass('define-active');
			page_.find('.define-page').eq(0).addClass('define-active');
		});

		// 尾页
		the_last_page.on('click',function () {
			page_.find('.define-page').removeClass('define-active');
			page_.find('.define-page').eq(4).addClass('define-active');
		});

	}

	/*页面*/
	//搜索功能
	search_function();
	function search_function() {
		$('#admin_search_people').click(function () {
			$('#search_form').submit();
		});
	}

	//超出滑动 样式
	style_set_overflow();
	function style_set_overflow() {
		var table_handle = $('#table_handle');
		var div = table_handle.parent();
		var thead = table_handle.find('thead').height();
		var tr = table_handle.find('tbody').find('tr').height();

		div.height( thead + tr * 9 );
	}

	//弹层 修正弹窗位置  始终处于屏幕中央
	function amend_modal_place($modal) {
		var window_width = $(window).width();
		var window_height = $(window).height();
		var width = $modal.width();
		var height = $modal.height();

		var left = ( window_width - width ) / 2;
		var top  = ( window_height - height ) / 2;

		$modal.css('left',left);
		$modal.css('top',top);
	}

	//页面  解除绑定
	page_unbind_function();
	function page_unbind_function() {
		var table_handle = $('#table_handle');//table
		table_handle.delegate('.define_unbind','click',function () {
			amend_modal_place($('#unbind_modal_tip'));
			$('#unbind_modal_tip').modal({keyboard: false});
		});
	}

});